home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / CRS / crs52.d81 / vdc-bg.sfx / vdc-bg.cvt (.txt) < prev   
GEOS ConVerT  |  1990-02-12  |  8KB  |  306 lines

  1. VDC-BG
  2. PRG formatted GEOS file V1.0
  3. Star NX-10
  4. OP V2.0 or higher
  5. Text  Scrap
  6. BLASTER'S CONVERTER V2.5
  7. testBGasm.rel
  8. VDC-BG.rel
  9. Write Image V2.1
  10. geoWrite    V2.1
  11. ; ****************************************************************************
  12. ;    VDC-BG : routines for a BG screen within VDC RAM on 64K VDC RAM C128's
  13. ;    Robert A. Knop Jr., Usenet Hacking Mag Issue #3
  14. ; ****************************************************************************
  15. .if    Pass1
  16. .noeqin
  17.      @.include    geosSym
  18. .include    128sym
  19. .include    geosMac
  20. .eqin
  21. .endif
  22. FGVDCBASE    =    $0000    ;Address in VDC of foreground screen
  23. BGVDCBASE    =    $4000    ;Address in VDC of background screen
  24. ; ***************************************************************************
  25. ;  InitVDC -- Makes sure your VDC is set up for 64K.  Have fun calling this one on a 16K VDC.
  26. ;    If you are motivated, modify this to verify that there is in fact have 64K of VDC
  27. ;    RAM, and return an error if there is only 16K.
  28. ;  Note -- Call this BEFORE you do any drawing on the screen, otherwise you will become
  29. ;      hopelessly confused.  At any rate, I probably will, and I won't even be there.
  30. ; ***************************************************************************
  31.      @InitVDC:
  32.     jsr    TempHideMouse
  33.     ldx    #28    ;Memory type register
  34.     jsr    ReadVDC
  35.     ora    #%00010000    ;Tell it we've got 64K
  36.     jsr    WriteVDC
  37.      @rts
  38. 's zero, then we're done
  39.     AddW    r6,r5
  40. ; *****************************************************************************
  41. ;     VDCImpRect -- Imprint a rectangle from FG to BG
  42. ;    VDCRecRect -- Recover a rectangle from BG to FG
  43. ;  Pass:    r3    x coordinate of upper left endpoint (word)
  44. ;    r2L    y coordinate of upper left endpoint (byte
  45. ;    r4    x coordinate of lower right endpoint (word)
  46. ;    r2H    y coordinate of lower right endpoint (byte)
  47. ;  Returns:    r3 and r4 processed through NormalizeX
  48. ;  Nukes: a,x,y , r5-r8,r10L,r11
  49. ;  Internal:    r5-r8,r11    ;Used in the VDC line routines
  50. ;    r10L    ;Flag for which routine we're in
  51. ; *****************************************************************************
  52.      @VDCImpRect:
  53.     LoadB    r10L,#$80
  54.     bne    contVDCrect
  55.      @VDCRecRect:
  56.     LoadB    r10L,#00
  57. contVDCrect:    PushB    r2L
  58. 5$    sta    r11L
  59.     bit    r10L
  60.     bmi    10$
  61.     jsr    VDCRecLine
  62.     bra    20$
  63. 10$    jsr    VDCImpLine
  64. 20$    inc    r2L
  65.     lda    r2L
  66.     cmp    r2H
  67.     bcc    5$
  68.     beq    5$
  69.     PopB    r2L
  70.      @rts
  71.  any rate, I probably will, and I won't even be there.
  72. ; *******************
  73. ; *****************************************************************************
  74. ;     VDCImpLine -- Imprint a horizontal line from FG to BG
  75. ;    VDCRecLine -- Recover a horizontal line from BG to FG
  76. ;  Pass:    r3    x coordinate of leftmost endpoint (word)
  77. ;    r4    x coordinate of rightmost endpoint (word)
  78. ;    r11L    y coordinate of line (byte)
  79. ;  Returns:    r3 and r4 processed through NormalizeX
  80. ;  Nukes: a,x,y , r5-r8,r11
  81. ;  Internal:    r5    ;Starting byte of block to copy
  82. ;    r6    ;Number of bytes to copy
  83. ;    r7    ;Starting byte of destination block
  84. ;    r8L    ;Left X mask
  85. ;    r8H    ;Right X mask
  86. ;    r11    ;Y byte offset; temp storage
  87. ; *****************************************************************************
  88.      @VDCImpLine:
  89.     jsr    GetDims    ;Get the dimensions of these scary things
  90.     AddVW    FGVDCBASE,r5
  91.     AddVW    BGVDCBASE,r7
  92.     bra    contVDCline
  93.      @VDCRecLine:
  94.     jsr    GetDims
  95.     AddVW    BGVDCBASE,r5
  96.     AddVW    FGVDCBASE,r7
  97. contVDCline:    jsr    SetVDC    ;Setup block copying
  98.     jsr    DoVDC    ;Do the copy of complete blocks
  99.     ldx    #r5
  100.     jsr    Ddec    ;Point to the "partial" byte
  101.     ldx    #r7
  102.     jsr    Ddec
  103.     ldy    r8L    ;Check left mask
  104.     beq    5$    ;If it's zero, don't worry about leftmost byte
  105.     jsr    Do1Byte    ;Do the one byte
  106. 5$    ldy    r8H    ;Check right mask
  107.     beq    90$    ;If 
  108. 's zero, then we're done
  109.     AddW    r6,r5
  110.     inc    r5L
  111.     bcc    10$
  112.     inc    r5H    ;Point to rightmost byte (source)
  113. 10$    AddW    r6,r7
  114.     inc    r7L
  115.     bcc    20$
  116.     inc    r7H    ;Point to rightmost byte (dest)
  117. 20$    jsr    Do1Byte
  118. 90$    jsr    RestVDC    ;Restore VDC
  119.      @rts
  120. GetDims:            
  121.      @;Get dimensions for VDCImpLine,VDCRecLine
  122.     ldx    #r3
  123.     jsr    NormalizeX    ;(Why someone would use BitMap
  124.     ldx    #r4    ; doubling in an 80-column only application
  125.     jsr    NormalizeX    ; is somewhat beyond me....)
  126.     LoadB    r8L,0
  127.     sta    r8H
  128.     sta    r11H
  129.     LoadW    r5,80
  130.     ldx    #r11
  131.     ldy    #r5
  132.     jsr    DMult    ;r11 *= 80
  133.     MoveW    r3,r5
  134.     ldx    #$02    ;Divide by 8
  135. 10$    lsr    r5H
  136.     ror    r5L
  137.     ror    r8L
  138.      dex
  139.     bpl    10$    ; ... so r5 has byte offset from start of line
  140.     ldx    #$04
  141. 20$    lsr    r8L
  142.     bpl    20$
  143.     ldx    r8L    ;r8L has remainder of division
  144.     beq    40$
  145.     LoadB    r8L,0
  146. 30$    sec
  147.     ror    r8L
  148.     bne    30$
  149.     lda    #$ff
  150.     eor    r8L
  151.     sta    r8L    ;Now r8L has the mask of the leftmost byte
  152.     inc    r5L
  153. ;...continued on next page....
  154. adB    r10L,#$80
  155.     bne    contVDCrect
  156.      @VDCRecRect:
  157.     LoadB    
  158. ;...GetDims continued....
  159. 40$    MoveW    r4,r6
  160.     inc    r6L    ;Point to one past last byte
  161.     bcc    45$
  162.     inc    r6H
  163. 45$    ldx    #$02    ;Divide by 8
  164. 50$    lsr    r6H
  165.     ror    r6L
  166.     ror    r8H
  167.      dex
  168.     bpl    50$    ; ... so r6 has byte offset from start of line
  169.     SubB    r5L,r6L    ;Now r6 has byte count
  170.     ldx    #$04
  171. 60$    lsr    r8H
  172.     bpl    60$
  173.     ldx    r8H    ;r8H has remainder of divisoin
  174.     beq    80$
  175.     LoadB    r8H,0
  176. 70$    sec
  177.     ror    r8H
  178.     bne    70$    ;r8H has mask of rightmost byte
  179. 80$    AddB    r11L,r5L
  180.     sta    r7L
  181.     lda    r11H
  182.     adc    r5H
  183.     sta    r5H
  184.     sta    r7H    ;r5, r7 have offset from screen top
  185.      @rts
  186. 30$    sec
  187.     ror    r8L
  188.     bne    30$
  189.     lda    #$ff
  190.     eor    r8L
  191.     sta    r8L    ;Now r8L has the mask of the leftmost byte
  192.     inc    r5L
  193. ;...continued on next page....
  194. adB    r10L,#$80
  195.     bne    contVDCrect
  196.      @VDCRecRect:
  197.     LoadB    
  198.      @SetVDC:
  199.     jsr    TempHideMouse    
  200.      @;Set up VDC for block copying
  201.     ldx    #24    ;Copy/fill register
  202.     jsr    ReadVDC
  203.     sta    VDCtemp
  204.     ora    #%10000000    ;Set for block copy
  205.     sta    $d601
  206.      @rts
  207.      @RestVDC:
  208.     lda    VDCtemp        
  209.      @;Restore original copy/fill status
  210.     ldx    #24
  211.     jsr    WriteVDC
  212.      @rts
  213. VDCtemp:
  214.     .byte    0
  215.      @DoVDC:
  216.     ldx    #18    
  217.      @;Copy the bulk of the scanline
  218.     lda    r7H    ;Block copy destination
  219.     jsr    WriteVDC
  220.     ldx    #19
  221.     lda    r7L
  222.     jsr    WriteVDC
  223.     ldx    #32    ;Block copy source
  224.     lda    r5H
  225.     jsr    WriteVDC
  226.     ldx    #33
  227.     lda    r5L
  228.     jsr    WriteVDC
  229.     ldx    #30    ;# bytes to copy
  230.     lda    r6L
  231.     jsr    WriteVDC    ;BANGO!
  232.      @    rts
  233.      @WriteVDC:
  234.     stx    $d600    
  235.      @;Writes a to VDC register x
  236. 10$    bit    $d600
  237.     bpl    10$
  238.     sta    $d601
  239.      @rts
  240. ReadVDC:
  241.     stx    $d600    
  242.      @;Reads a from VDC register x
  243. 10$    bit    $d600
  244.     bpl    10$
  245.     lda    $d601
  246.      @rts
  247.      @Do1Byte:
  248.     sty    r11H    ;r11H holds the mask
  249.     ldx    #18    ;Point to the source screen byte
  250.     lda    r5H
  251.     jsr    WriteVDC
  252.     ldx    #19
  253.     lda    r5L
  254.     jsr    WriteVDC
  255.     ldx    #31
  256.     jsr    Rea
  257.      @Do1Byte:
  258.     sty    r11H    ;r11H holds the mask
  259.     ldx    #18    ;Point to the source screen byte
  260.     lda    r5H
  261.     jsr    WriteVDC
  262.     ldx    #19
  263.     lda    r5L
  264.     jsr    WriteVDC
  265.     ldx    #31
  266.     jsr    ReadVDC    ;Get the value of this byte
  267.     and    r11H    ;Mask off bits that we don't modify
  268.     sta    r11L    ;save the result
  269.     lda    r11H
  270.     eor    #$ff    ;flip the bits in the mask
  271.     sta    r11H
  272.     ldx    #18    ;Point to the dest screen byte
  273.     lda    r7H
  274.     jsr    WriteVDC
  275.     ldx    #19
  276.     lda    r7L
  277.     jsr    WriteVDC
  278.     ldx    #31
  279.     jsr    ReadVDC    ;Get the value of this byte
  280.     and    r11H    ;Mask out the bits to change
  281.     ora    r11L    ;...and load those bits in
  282.     ldx    #18    ;Point to the dest screen byte
  283.     lda    r7H    ; (reset the poitner because of the VDC's
  284.     jsr    WriteVDC    ;  auto-increment)
  285.     ldx    #19
  286.     lda    r7L
  287.     jsr    WriteVDC
  288.     ldx    #31
  289.     jsr    WriteVDC
  290.      @rts
  291. ;Reads a from VDC register x
  292. 10$    bit    $d600
  293.     bpl    10$
  294.     lda    $d601
  295.      @rts
  296.      @Do1Byte:
  297.     sty    r11H    ;r11H holds the mask
  298.     ldx    #18    ;Point to the source screen byte
  299.     lda    r5H
  300.     jsr    WriteVDC
  301.     ldx    #19
  302.     lda    r5L
  303.     jsr    WriteVDC
  304.     ldx    #31
  305.     jsr    Rea
  306.